preliminary = {'S01', 'S02', 'S03', 'S04', 'S05', 'S06'}
final = {'S02', 'S04', 'S06', 'S07', 'S08'}
both_participated = preliminary.intersection(final)
print(f"同时参加了初赛和复赛的学生学号: {both_participated}")
all_participated = preliminary.union(final)
print(f"所有参加了比赛的学生学号（去重）: {all_participated}")
only_preliminary = preliminary.difference(final)
print(f"只参加了初赛，没有参加复赛的学生学号: {only_preliminary}")